package cn.crex1.xiaomi.util;

import java.util.UUID;
import java.util.regex.Pattern;



public class StringUtil {
	private static Object bloker=new Object();
	
	public static Integer intValue(String str) {
		return Integer.parseUnsignedInt(str);
	}
	
	public static String stringValue(Object number) {
		return String.valueOf(number);	
	}
	
	public static boolean isNull(String args) {
		if (args==null) {
			return true;
		}
		return false;
	}
	
	public static boolean isEmpty(String args) {
		if (args=="") {
			return true;
		}
		return false;
	}
	
	public static boolean isExists(String args) {
		if (isNull(args) || isEmpty(args)) {
			return false;
		}
		return true;
	}
	
	public static String token() {
		synchronized (bloker) {
			String token = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 9);			
			return token;
		}
	}
	
	public static boolean isInteger(String str) {
		Pattern pattern=Pattern.compile("^[-\\+]?[\\d]*$");
		return pattern.matcher(str).matches();
	}
}
